<template>
    <div> 
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in newsList" :key="item.channelid">
                <!-- <router-link :to="{path:'/home/newsInfo',query: {ch_name: item.ch_name}}"> -->
                <router-link :to="'/home/newsInfo/' + item.id">
                    <img class="mui-media-object mui-pull-left" :src="item.thumbnail">
                    <div class="mui-media-body">
                        <h3>{{ item.name }}}</h3>
                        <p class="mui-ellipsis">
                            <span>{{ item.description }}</span>
                            <!-- <span>{{ item.channelid }}</span> -->
                        </p>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>

<script>
// import { Toast } from 'mint-ui';
export default {
    data() {
        return {
            newsList: [] //新闻列表
        }
    },
    created(){
        this.getNewslist();
    },
    methods: {
        getNewslist() {  //获取新闻列表
            this.$http.get('/api/sections').then(result => {
                // if(result.body.code === 200){
                //     //如果没有失败, 应该把数据 保存到 data 上
                //     //console.log(result.body.result)
                //     this.newsList = result.body.result[0].channellist
                // }else{
                //     Toast('获取新闻列表失败')
                // }
                //console.log(result.body.data)
                this.newsList = result.body.data
            })
        }
    }
}
</script>

<style lang="scss" scoped>
.mui-media-body{
    h3{
        font-size: 13px;
    }
    .mui-ellipsis{
        color: #999;
        font-size: 12px;
        // display: flex;
        // justify-content: space-between;
    }
}
</style>

